<template>
  <div>
    <Header :isLogin="isLogin" :newMsg="newMsg" />
    <Slidershow />
    <Section :items="sections" />
    <Item :items="items"/>
    <Recommend :recommeds="recommeds"/>
    <Footer />
  </div>
</template>

<script>
import Header from "../../../header/header";
import Slidershow from "../../buyer/index/slidershow";
import Section from "../../buyer/index/section";
import Item from "../../buyer/index/item";
import Recommend from "../../buyer/index/recommend";
import Footer from "../../../footer/footer";
export default {
  components: {
    Header,
    Slidershow,
    Section,
    Item,
    Recommend,
    Footer
  },
  data() {
    return {
      isLogin: false,
      newMsg: false,
      items:[],
      recommeds:[],
      sections:[]
    };
  },
  mounted() {
    this.axios.get("/user/info").then((resp)=>{
        if(resp.code != 0){
          this.$router.push("/")
        }else{
          this.EventBus.$emit("isLogin",true,resp.data.newMsg,resp.data.role)
        }
      })
      this.axios.post("/product/search",{
          "page":1,
          "size":15,
        }).then((resp)=>{
          if(resp.code==0){
              this.sections = resp.data.records.slice(0,5)
              this.items = resp.data.records.slice(6,10)
              this.recommeds = resp.data.records.slice(11,15)
              
          }
      })
  }
};
</script>

<style scoped>
</style>
